package utils;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.ValueFilter;

/**
 * Created by zhangliangxue on 2017/11/29.
 */
public class CommonUtill {
	
	public void OutputJson(Object object,HttpServletResponse response,HttpServletRequest request) {
		PrintWriter out = null;
		response.setContentType("application/json");
		response.setCharacterEncoding("utf-8");
		String json=null;
		try {
			out = response.getWriter();
			json = JSONObject.toJSONString(object,filter);//JSON.toJSONStringWithDateFormat(object, "yyyy-MM-dd HH:mm:ss");
		} catch (IOException e) {
			e.printStackTrace();
		}
		out.print(json);
		out.close();
	}

	private static ValueFilter filter = new ValueFilter() {

//        @Override
        public Object process(Object obj, String s, Object v) {
            if (v == null) {
				return "";
			}else {
				return v;
			}
        }
    };

	
}
